# Contributor: Milan P. Stanić <mps@arvanta.net>
# Maintainer: Milan P. Stanić <mps@arvanta.net>
pkgname=speakersafetyd
pkgver=1.0.2
pkgrel=0
pkgdesc="asahi linux speaker safety daemon"
url="https://github.com/AsahiLinux/speakersafetyd"
arch="aarch64"
license="MIT"
depends="alsa-ucm-conf-asahi"
makedepends="alsa-lib-dev cargo cargo-auditable"
subpackages="$pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://github.com/AsahiLinux/speakersafetyd/archive/refs/tags/$pkgver.tar.gz
	speakersafetyd.initd
	"
options="net" # Required to download crates

prepare() {
	default_prepare
	cargo update -p speakersafetyd
	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --frozen --release
}

package() {
	make DESTDIR=$pkgdir UDEVDIR=/usr/lib/udev/rules.d install
	install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname

	# We don't ship systemd
	rm -r "$pkgdir"/lib
}

sha512sums="
efd39e5e9479995d5b531070b7824db7e279b399b893b3effc64020183eb7017b6f217dbee36b22b9b37f3c63da74dfa1551d07cbaead5d8aa3b37722c11126a  speakersafetyd-1.0.2.tar.gz
d577e5c96f240198bd1adff609944c678e725bd6db3378711f3e02d9cad1d6c058d0031c4aa5c91445d63ead6b037ebcffe377f764ba11261e05d72a73f77f7b  speakersafetyd.initd
"
